<!DOCTYPE html>
<html>
<head>
    <meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1">
    <title>数据库结构对比</title>
	
    <script src="js/vue.js"></script>
    <link rel="stylesheet" href="js/element-ui/lib/theme-chalk/index.css">
    <script src="js/element-ui/lib/index.js"></script>
    <script src="js/axios.js"></script>

    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/index.css">
</head>
<body>
    <div id="app" v-cloak>
        <div class="header-panel">
			<div><h2>数据库连接信息列表</h2></div>
			<div></div>
			<div><el-button type="success" icon="el-icon-circle-plus" size="medium" @click="showAddDialog()">添加数据库信息</el-button></div>
		</div>
        <div class="body-panel">
            <div class="operate-panel">
				<div class="operate-item">
					<div>
						差异报告
						<el-popover
							placement="right-start"
							title="简介"
							width="200"
							trigger="hover"
							content="对比两个数据库之间的差异变化，用于评审检查数据库的变动">
							<i slot="reference" class="el-icon-question"></i>
						</el-popover>
					</div>
					<div class="operate-item-input">
						<span>先遣库：</span>
						<el-input
							style="width: 180px;"
							placeholder="请输入数据库的序号"
							v-model="paramReport.change"
							clearable>
						</el-input>
					</div>
					<div class="operate-item-input">
						<span>滞后库：</span>
						<el-input
							style="width: 180px;"
							placeholder="请输入数据库的序号"
							v-model="paramReport.target"
							clearable>
						</el-input>
					</div>
					<div><div><el-button type="success" icon="el-icon-success" size="medium" @click="toReportPage()">生成</el-button></div></div>
				</div>
				<div class="operate-item">
					<div>
						差异SQL
						<el-popover
							placement="right-start"
							title="简介"
							width="200"
							trigger="hover"
							content="对比先遣库之后,生成的差异sql，在滞后库上执行即可补齐差异。（注意：sql语句仅供参考，执行前应当检查一下sql，出现数据丢失一概不负责）">
							<i slot="reference" class="el-icon-question"></i>
						</el-popover>
					</div>
					<div class="operate-item-input">
						<span>先遣库：</span>
						<el-input
							style="width: 180px;"
							placeholder="请输入数据库的序号"
							v-model="paramSql.change"
							clearable>
						</el-input>
					</div>
					<div class="operate-item-input">
						<span>滞后库：</span>
						<el-input
							style="width: 180px;"
							placeholder="请输入数据库的序号"
							v-model="paramSql.target"
							clearable>
						</el-input>
					</div>
					<div>
						<div>
							<el-button type="success" icon="el-icon-success" size="medium" @click="toSqlStructPage()">结构差异</el-button>
							<el-button type="success" icon="el-icon-success" size="medium" @click="showSqlDataDifferentDialog()">数据差异</el-button>
						</div>
					</div>
				</div>
				<div class="operate-item">
					<div>
						规范检查
						<el-popover
							placement="right-start"
							title="简介"
							width="200"
							trigger="hover"
							content="根据《阿里巴巴java开发手册_1.7.0嵩山版》对先遣库的数据库设计进行规范检查">
							<i slot="reference" class="el-icon-question"></i>
						</el-popover>
					</div>
					<div class="operate-item-input">
						<span>数据库：</span>
						<el-input
							style="width: 180px;"
							placeholder="请输入数据库的序号"
							v-model="paramCheck.change"
							clearable>
						</el-input>
					</div>
					<div>
						<div>
							<el-button type="success" icon="el-icon-success" size="medium" @click="toCheckPage()">生成</el-button>
							<el-button type="success" icon="el-icon-success" size="medium" @click="showCheckDialog()">自定义检查</el-button>
						</div>
					</div>
				</div>
				<div class="operate-item">
					<div>
						逆向生成
						<el-popover
							placement="right-start"
							title="简介"
							width="200"
							trigger="hover"
							content="一键生成entity.java，mapper.java，mapper.xml，service.java，serviceImpl.java，controller.java文件">
							<i slot="reference" class="el-icon-question"></i>
						</el-popover>
					</div>
					<div>
						<div>
							<el-button type="success" icon="el-icon-success" size="medium" @click="showGeneratorDialog()">配置生成</el-button>
						</div>
					</div>
				</div>
            </div>
            <div class="table-panel" v-loading="loading">
                <el-table :data="tableData" stripe style="width: 100%">
                    <el-table-column prop="key" label="序号" width="80"></el-table-column>
                    <el-table-column prop="name" label="连接名"></el-table-column>
                    <el-table-column prop="host" label="主机"></el-table-column>
					<el-table-column prop="port" label="端口"></el-table-column>
					<el-table-column prop="userName" label="用户名"></el-table-column>
					<!-- <el-table-column prop="password" label="密码"></el-table-column> -->
					<el-table-column prop="database" label="数据库"></el-table-column>
					<el-table-column label="操作" width="100">
						<template slot-scope="scope">
							<el-button type="text" size="small" @click="showUpdateDialog(scope.row)">修改</el-button>
							<el-button type="text" size="small" style="color: red;" @click="showDeleteDialog(scope.row)">删除</el-button>
						</template>
					</el-table-column>
                </el-table>
            </div>
        </div>
		<el-dialog title="自定义规范检查" :close-on-click-modal=false :close-on-press-escape=false :visible.sync="isShowCheckDialog" width="600px">
			<div>
				<el-checkbox :indeterminate="isRegulationCheckIndeterminate" v-model="checkAllRegulationCheckType" @change="handleCheckAllRegulationCheck">全选</el-checkbox>
				<div style="margin: 15px 0;"></div>
				<el-checkbox-group v-model="checkedRegulationCheckTypeListOptions" @change="handleCheckedRegulationCheck">
					<el-checkbox v-for="item in regulationCheckTypeListOptions" :label="item" :key="item">{{item}}</el-checkbox>
				</el-checkbox-group>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button type="success" @click="showSpellingDialog()" v-if="isShowSpelling" plain>设置忽略拼写词</el-button>
				<el-button type="primary" @click="showPluralizeDialog()" v-if="isShowPluralize" plain>设置忽略复数词</el-button>
				<el-button @click="isShowCheckDialog = false">取消</el-button>
				<el-button type="success" @click="toCheckPage2()">确定</el-button>
			</span>
		</el-dialog>
		<el-dialog title="设置忽略拼写词" :close-on-click-modal=false :close-on-press-escape=false :visible.sync="isShowSpellingDialog" width="550px">
			<div>
				<el-input type="textarea" :rows="10" placeholder="请输入忽略检查拼写的单词，用英文逗号隔开" v-model="ignoreSpellingWordStr">
				</el-input>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="isShowSpellingDialog = false">取消</el-button>
				<el-button type="success" @click="setIgnoreWords(checkSpellingTypeCode)">确定</el-button>
			</span>
		</el-dialog>
		<el-dialog title="设置忽略复数词" :close-on-click-modal=false :close-on-press-escape=false :visible.sync="isShowPluralizeDialog" width="550px">
			<div>
				<el-input type="textarea" :rows="10" placeholder="请输入忽略检查复数的单词，用英文逗号隔开" v-model="ignorePluralizeWordStr">
				</el-input>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="isShowPluralizeDialog = false">取消</el-button>
				<el-button type="success" @click="setIgnoreWords(checkPluralizeTypeCode)">确定</el-button>
			</span>
		</el-dialog>
		<el-dialog :title="addDialogTitle" :close-on-click-modal=false :close-on-press-escape=false :visible.sync="isShowAddDialog" width="500px">
			<el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
				<el-form-item label="连接名" prop="name">
					<el-input v-model="ruleForm.name" placeholder="请输入连接名"></el-input>
				</el-form-item>
				<el-form-item label="主机" prop="host">
					<el-input v-model="ruleForm.host" placeholder="请输入主机ip或域名"></el-input>
				</el-form-item>
				<el-form-item label="端口" prop="port">
					<el-input v-model.number="ruleForm.port" placeholder="请输入端口号"></el-input>
				</el-form-item>
				<el-form-item label="用户名" prop="userName">
					<el-input v-model="ruleForm.userName" placeholder="请输入数据库用户名"></el-input>
				</el-form-item>
				<el-form-item label="密码" prop="password">
					<el-input type="password" v-model="ruleForm.password" autocomplete="off" placeholder="请输入数据库密码" show-password></el-input>
				</el-form-item>
				<el-form-item label="数据库" prop="database">
					<el-input v-model="ruleForm.database" placeholder="请输入数据库名称"></el-input>
				</el-form-item>
				<!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="isShowAddDialog = false">取消</el-button>
				<el-button type="success" @click="submitForm('ruleForm')" v-loading.fullscreen.lock="fullScreenLoading">确定</el-button>
			</span>
		</el-dialog>
		<el-dialog title="数据库逆向生成代码" :close-on-click-modal=false :close-on-press-escape=false :visible.sync="isShowGeneratorDialog" width="1000px">
			<el-form :model="ruleGeneratorForm" status-icon :rules="ruleGenerator" ref="ruleGeneratorForm" label-width="100px" class="demo-ruleForm">
				<div style="display: flex;">
					<el-form-item  style="flex: 0 210px;" label="数据库序号" prop="databaseKey">
						<el-input v-model="ruleGeneratorForm.databaseKey" placeholder="请输入序号"></el-input>
					</el-form-item>
					<el-form-item  style="flex:1" label="数据库表名" prop="tableName">
						<el-input v-model="ruleGeneratorForm.tableName" placeholder="请输入数据库表名，多个时用英文逗号隔开，支持*号匹配，例如：t_user_*,t_sys_login"></el-input>
					</el-form-item>
				</div>
				
				<el-form-item label="生成文件">
					<!-- entity.java，mapper.java，mapper.xml，service.java，serviceImpl.java，controller.java -->
					<div style="display: flex;">
						<el-checkbox style="flex: 0 165px;" v-model="ruleGeneratorForm.isGenEntity">entity.java</el-checkbox>
						包名: &nbsp;&nbsp;
						<el-input style="flex:1" v-model="ruleGeneratorForm.packageEntityName" placeholder="请输入Entity的包名，例如：com.sqb.test.entity"></el-input>
						<div style="flex: 0 120px; display: flex; align-items: center; justify-content: flex-end;">
							<el-button type="success" @click="fillGeneratorFormData()">向下填充</el-button>
						</div>
					</div>
					<div style="height: 15px;">&nbsp;&nbsp;</div>
					<div style="display: flex;">
						<el-checkbox style="flex: 0 165px;" v-model="ruleGeneratorForm.isGenMapper">mapper.java</el-checkbox>
						包名: &nbsp;&nbsp;
						<el-input style="flex:1" v-model="ruleGeneratorForm.packageMapperName" placeholder="请输入Mapper的包名，例如：com.sqb.test.mapper"></el-input>
					</div>
					<div style="height: 15px;">&nbsp;&nbsp;</div>
					<div style="display: flex;">
						<el-checkbox style="flex: 0 165px;" v-model="ruleGeneratorForm.isGenMapperXml">mapper.xml</el-checkbox>
						包名:&nbsp;&nbsp;
						<el-input style="flex:1" v-model="ruleGeneratorForm.packageMapperXmlName" placeholder="请输入Mapper的包名，例如：com.sqb.test.mapper"></el-input>
					</div>
					<div style="height: 15px;">&nbsp;&nbsp;</div>
					<div style="display: flex;">
						<el-checkbox style="flex: 0 165px;" v-model="ruleGeneratorForm.isGenService">service.java</el-checkbox>
						包名:&nbsp;&nbsp;
						<el-input style="flex:1" v-model="ruleGeneratorForm.packageServiceName" placeholder="请输入Service的包名，例如：com.sqb.test.service"></el-input>
					</div>
					<div style="height: 15px;">&nbsp;&nbsp;</div>
					<div style="display: flex;">
						<el-checkbox style="flex: 0 165px;" v-model="ruleGeneratorForm.isGenServiceImpl">serviceImpl.java</el-checkbox>
						包名:&nbsp;&nbsp;
						<el-input style="flex:1" v-model="ruleGeneratorForm.packageServiceImplName" placeholder="请输入ServiceImpl的包名，例如：com.sqb.test.service.impl"></el-input>
					</div>
					<div style="height: 15px;">&nbsp;&nbsp;</div>
					<div style="display: flex;">
						<el-checkbox style="flex: 0 165px;" v-model="ruleGeneratorForm.isGenController">controller.java</el-checkbox>
						包名:&nbsp;&nbsp;
						<el-input style="flex:1" v-model="ruleGeneratorForm.packageControllerName" placeholder="请输入controller的包名，例如：com.sqb.test.controller"></el-input>
					</div>
				</el-form-item>
				<el-form-item label="文件名忽略">
					<div style="display: flex;">
						<el-checkbox style="flex: 0 200px;" v-model="ruleGeneratorForm.isIgnoreFixPrefix">文件名忽略表名的前缀“t_”</el-checkbox>
						<el-checkbox style="flex: 0 120px;" v-model="ruleGeneratorForm.isIgnoreOtherPrefix">其他表名前缀: </el-checkbox>
						<el-input style="flex:1" v-model="ruleGeneratorForm.ignoreOtherPrefix" placeholder="请输入表名前缀，多个时用英文逗号隔开"></el-input>
					</div>
				</el-form-item>
				<div style="background-color: #f0f9eb; color: #67C23A; font-size: 13px; box-sizing: border-box; padding: 20px; display: flex;">
					<div style="box-sizing: border-box; padding-bottom: 10px; flex: 0 40px;">提示</div>
					<div style="flex: 1;">
						<div style="box-sizing: border-box; padding-bottom: 10px;">1.生成文件所在磁盘目录：当前运行的jar文件夹 -> database-compare-data文件夹 -> generatorFile开头的文件夹</div>
						<div>2.数据库字段类型映射：在代码的 FieldTypeMappingEnum 枚举</div>
					</div>
				</div>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="isShowGeneratorDialog = false">取消</el-button>
				<el-button type="success" @click="submitGeneratorForm('ruleGeneratorForm')">确认生成</el-button>
			</span>
		</el-dialog>
		<el-dialog title="填写表名和查询条件" :close-on-click-modal=false :close-on-press-escape=false :visible.sync="isShowSqlDataDifferentDialog" width="750px">
			<div style="display: flex;">
				<div style="flex:0 100px; display: flex; justify-content: left; align-items: center;">对比表名：</div><el-input placeholder="请输入数据库表名" v-model="dataDifferentTableName"></el-input>
			</div>
			<div style="height: 40px;"></div>
			<div style="display: flex;">
				<div style="flex:0 100px; display: flex; justify-content: left; align-items: center;">对比字段名：</div><el-input placeholder="where语句后面的条件字段名，多个时用英文逗号隔开，例如:school_id,user_id" v-model="dataDifferentFieldName"></el-input>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="isShowSqlDataDifferentDialog = false">取消</el-button>
				<el-button type="success" @click="toSqlDataPage()">确定生成</el-button>
			</span>
		</el-dialog>
		<iframe src="component/footer.html" onload="this.before((this.contentDocument.body||this.contentDocument).children[0]);this.remove()"></iframe>
    </div>

    <script src="js/utils.js"></script>
    <script>
        let that = new Vue({
            el: '#app',
			computed: {
				isShowSpelling: function(){
					let regulationCheckTypeSpellingObj = this.regulationCheckTypeList.filter(item => item.code == this.checkSpellingTypeCode)[0];
					for (let i=0; i<this.checkedRegulationCheckTypeListOptions.length; i++) {
						if (this.checkedRegulationCheckTypeListOptions[i] == regulationCheckTypeSpellingObj.desc) {
							return true;
						}
					}
					return false;
				},
				isShowPluralize: function(){
					let regulationCheckTypePluralizeObj = this.regulationCheckTypeList.filter(item => item.code == this.checkPluralizeTypeCode)[0];
					for (let i=0; i<this.checkedRegulationCheckTypeListOptions.length; i++) {
						if (this.checkedRegulationCheckTypeListOptions[i] == regulationCheckTypePluralizeObj.desc) {
							return true;
						}
					}
					return false;
				},
			},
            data: function () {
				var checkPort = (rule, value, callback) => {
					if (!value) {
						return callback(new Error('端口不能为空'));
					}
					setTimeout(() => {
						if (!Number.isInteger(value)) {
							callback(new Error('请输入数字值'));
						} else {
							callback();
						}
					}, 1000);
				};
				var checkEmpty = (rule, value, callback) => {
					if (!value) {
						return callback(new Error('不能为空'));
					} else {
						callback();
					}
				};
                return {
					checkSpellingTypeCode: '12',
					checkPluralizeTypeCode: '31',
					loading: false,
					fullScreenLoading: false,
					addDialogTitle:"新增数据库连接",
					isShowCheckDialog:false,
                    isShowAddDialog: false,
                    isShowSpellingDialog: false,
                    isShowPluralizeDialog: false,
					isShowGeneratorDialog: false,
					isShowSqlDataDifferentDialog: false,
					ignoreSpellingWordStr:"",
					ignorePluralizeWordStr:"",
					paramReport:{
						change:"",
						target:"",
					},
					paramSql:{
						change:"",
						target:"",
					},
					paramCheck:{
						change:"",
					},
                    tableData: [{
						key: 1,
                        name: '王小虎',
                        host: '127.0.0.1',
						port: 3306,
						userName: 'root',
						password: '123',
						database: 'school',
                    }],
					ruleForm: {
						key: null,
						name: '',
						host: '',
						port: 3306,
						userName: '',
						password: '',
						database: '',
					},
					ruleGeneratorForm: {
						databaseKey: null,
						tableName: '',
						isGenEntity: true,
						isGenMapper: true,
						isGenMapperXml: true,
						isGenService: true,
						isGenServiceImpl: true,
						isGenController: true,
						
						packageEntityName:"",
						packageMapperName:"",
						packageMapperXmlName:"",
						packageServiceName:"",
						packageServiceImplName:"",
						packageControllerName:"",
						
						ignoreTablePrefix:"",
						
						isIgnoreFixPrefix: true,
						isIgnoreOtherPrefix: false,
						ignoreOtherPrefix:"",
					},
					rules: {
						name: [
							{ validator: checkEmpty, trigger: 'blur' }
						],
						host: [
							{ validator: checkEmpty, trigger: 'blur' }
						],
						port: [
							{ validator: checkPort, trigger: 'blur' }
						],
						userName: [
							{ validator: checkEmpty, trigger: 'blur' }
						],
						database: [
							{ validator: checkEmpty, trigger: 'blur' }
						],
					},
					ruleGenerator: {
						
					},
					checkAllRegulationCheckType: false,
					isRegulationCheckIndeterminate: true,
					regulationCheckTypeList:[],
					regulationCheckTypeListOptions:[],
					checkedRegulationCheckTypeListOptions: [],
					dataDifferentTableName:"",
					dataDifferentFieldName:"",
                }
            },
            methods: {
				// 展示添加数据库连接的弹窗
				showAddDialog(){
					this.addDialogTitle = "新增数据库连接";
					this.ruleForm.key = null;
					this.isShowAddDialog = true;
					// 暂时不要重置，不然每次都要输入数据
					// this.resetForm('ruleForm');
				},
				// 展示编辑数据库连接的弹窗
				showUpdateDialog(data){
					this.addDialogTitle = "修改数据库连接";
					this.isShowAddDialog = true;
					this.$nextTick(()=>{
						copyProperties(data, this.ruleForm, true);
					})
				},
				// 展示自定义规范检查弹窗
				showCheckDialog(){
					if (!this.paramCheck.change) {
						this.$message({type: 'error', message: "请填写先遣库的key"});
						return false;
					}
					this.isShowCheckDialog = true;
				},
				// 展示逆向生成配置弹窗
				showGeneratorDialog(){
					this.isShowGeneratorDialog = true;
				},
				// 展示单词拼写配置弹窗
				showSpellingDialog(){
					this.getIgnoreWords(this.checkSpellingTypeCode);
					this.isShowSpellingDialog = true;
				},
				// 展示复数词配置弹窗
				showPluralizeDialog(){
					this.getIgnoreWords(this.checkPluralizeTypeCode);
					this.isShowPluralizeDialog = true;
				},
				// 展示删除数据库连接记录确认窗
				showDeleteDialog(row){
					this.$confirm(`是否删除“${row.name}”?`, '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						this.loading = true;
						axios.get(`${baseUrl}/api/delete?key=${row.key}`)
						.then(response => {
							if (response.data.code == 200) {
								this.$message({type: 'success', message: '删除成功'});
								this.list();
							} else {
								this.$message({type: 'error', message: response.msg});
							}
						})
						.catch(error => {
							console.log(error);
							this.$message({type: 'error', message: '请求失败'});
						})
						.finally(() => {
							this.loading = false;
						})
					}).catch(() => {
						        
					});
				},
				showSqlDataDifferentDialog() {
					if (!this.paramSql.change) {
						this.$message({type: 'error', message: "请填写先遣库的key"});
						return false;
					}
					if (!this.paramSql.target) {
						this.$message({type: 'error', message: "请填写滞后库的key"});
						return false;
					}
					this.isShowSqlDataDifferentDialog = true;
				},
				// 处理自定义规范检查全选事件
				handleCheckAllRegulationCheck(val) {
					this.checkedRegulationCheckTypeListOptions = val ? this.regulationCheckTypeListOptions : [];
					this.isRegulationCheckIndeterminate = false;
				},
				// 处理自定义规范检查某个选项选中的事件
				handleCheckedRegulationCheck(value) {
					let checkedCount = value.length;
					this.checkAllRegulationCheckType = checkedCount === this.regulationCheckTypeListOptions.length;
					this.isRegulationCheckIndeterminate = checkedCount > 0 && checkedCount < this.regulationCheckTypeListOptions.length;
				},
				// 跳转到差异报告页面
				toReportPage(){
					if (!this.paramReport.change) {
						this.$message({type: 'error', message: "请填写先遣库的key"});
						return false;
					}
					if (!this.paramReport.target) {
						this.$message({type: 'error', message: "请填写滞后库的key"});
						return false;
					}
					window.open(`report.html?changeKey=${this.paramReport.change}&targetKey=${this.paramReport.target}`);
				},
				// 跳转到差异sql页面
				toSqlStructPage(){
					if (!this.paramSql.change) {
						this.$message({type: 'error', message: "请填写先遣库的key"});
						return false;
					}
					if (!this.paramSql.target) {
						this.$message({type: 'error', message: "请填写滞后库的key"});
						return false;
					}
					window.open(`sql.html?type=struct&changeKey=${this.paramSql.change}&targetKey=${this.paramSql.target}`);
				},
				toSqlDataPage() {
					if (!this.paramSql.change) {
						this.$message({type: 'error', message: "请填写先遣库的key"});
						return false;
					}
					if (!this.paramSql.target) {
						this.$message({type: 'error', message: "请填写滞后库的key"});
						return false;
					}
					if (!this.dataDifferentTableName || this.dataDifferentTableName == "") {
						this.$message({type: 'error', message: "请填写表名"});
						return false;
					}
					if (!this.dataDifferentFieldName || this.dataDifferentFieldName == "") {
						this.$message({type: 'error', message: "请填写字段名"});
						return false;
					}
					window.open(`sql.html?type=data&changeKey=${this.paramSql.change}&targetKey=${this.paramSql.target}&tableName=${this.dataDifferentTableName}&fieldName=${this.dataDifferentFieldName}`);
				},
				// 跳转到规范检查页面
				toCheckPage(){
					if (!this.paramCheck.change) {
						this.$message({type: 'error', message: "请填写先遣库的key"});
						return false;
					}
					let checkIds = "";
					for (let i=0; i<this.regulationCheckTypeList.length; i++) {
						checkIds += (i==0 ? '' : ',') + this.regulationCheckTypeList[i].code;
					}
					window.open(`check.html?changeKey=${this.paramCheck.change}&checkIds=${checkIds}`);
				},
				// 跳到自定义规范检查结果页面
				toCheckPage2(){
					let checkIds = "";
					if (this.checkedRegulationCheckTypeListOptions.length <= 0) {
						this.$message({type: 'error', message: "请勾选检查项"});
						return false;
					} else {
						for (let i=0; i<this.regulationCheckTypeList.length; i++) {
							for (let j=0; j<this.checkedRegulationCheckTypeListOptions.length; j++) {
								if (this.checkedRegulationCheckTypeListOptions[j] == this.regulationCheckTypeList[i].desc) {
									checkIds += "," + this.regulationCheckTypeList[i].code;
								}
							}
						}
						checkIds = checkIds.substring(1);
						window.open(`check.html?changeKey=${this.paramCheck.change}&checkIds=${checkIds}`);
					}
				},
				// 重置表单
				resetForm(formName) {
					if (this.$refs[formName] != undefined) {
						this.$refs[formName].resetFields();
					} else {
						console.log("有没有搞错，是undefined");
					}
				},
				// 保存数据库连接信息
				submitForm(formName) {
					this.$refs[formName].validate((valid) => {
						if (valid) {
							this.loading = true;
							axios.post(`${baseUrl}/api/save`, this.ruleForm)
							    .then(response => {
							        if (response.data.code == 200) {
										this.$message({type: 'success', message: '保存成功'});
							            this.list();
										this.isShowAddDialog = false;
							        } else {
										this.$message({type: 'error', message: response.msg});
							        }
							    })
							    .catch(error => {
							        console.log(error);
									this.$message({type: 'error', message: '请求失败'});
							    })
							    .finally(() => {
							        this.loading = false;
							    })
						} else {
							console.log('error submit!!');
							return false;
						}
					});
				},
				// 提交代码逆向生成的表单数据（即触发生成逆向代码）
				submitGeneratorForm(formName){
					let ignoreTablePrefix = '';
					if (this.ruleGeneratorForm.isIgnoreOtherPrefix && this.ruleGeneratorForm.ignoreOtherPrefix.length > 0) {
						ignoreTablePrefix = this.ruleGeneratorForm.ignorePrefix;
					}
					if (this.ruleGeneratorForm.isIgnoreFixPrefix) {
						ignoreTablePrefix += (ignoreTablePrefix.length > 0 ? "," : "") + "t_";
					}
					this.ruleGeneratorForm.ignoreTablePrefix = ignoreTablePrefix;
					this.fullScreenLoading = true;
					// 存储一下表单数据，方便下次操作
					localStorage.setItem("ruleGeneratorForm", JSON.stringify(this.ruleGeneratorForm));
					axios.post(`${baseUrl}/api/generateCodeFile`, this.ruleGeneratorForm).then(response => {
						if (response.data.code == 200) {
							this.$message({type: 'success', message: '生成成功'});
						} else {
							this.$message({type: 'error', message: response.data.msg});
						}
					})
					.catch(error => {
						console.log(error);
						this.$message({type: 'error', message: '请求失败'});
					})
					.finally(() => {
						this.fullScreenLoading = false;
					})
				},
				// 查询数据库连接信息列表
				list(){
					axios.get(`${baseUrl}/api/list`).then(response => {
						this.tableData = response.data.result;
					}).catch(error => {
						console.log(error);
					})
				},
				// 查询自定义检查项的数据
				listRegulationCheckType(){
					axios.get(`${baseUrl}/api/listRegulationCheckType`).then(response => {
						let result = response.data.result;
						this.regulationCheckTypeList = result;
						for (let i=0; i<this.regulationCheckTypeList.length; i++) {
							this.regulationCheckTypeListOptions.push(this.regulationCheckTypeList[i].desc);
						}
					}).catch(error => {
						console.log(error);
					})
				},
				// 查询单词拼写忽略词数据
				getIgnoreWords(code){
					axios.get(`${baseUrl}/api/getIgnoreWords?code=${code}`).then(response => {
						if (code == this.checkSpellingTypeCode) {
							this.ignoreSpellingWordStr = response.data.result;
						} else if (code == this.checkPluralizeTypeCode) {
							this.ignorePluralizeWordStr = response.data.result;
						}
					}).catch(error => {
						console.log(error);
					})
				},
				// 设置并保存单词拼写忽略词数据
				setIgnoreWords(code){
					let ignoreWords = code == this.checkSpellingTypeCode ? this.ignoreSpellingWordStr : this.ignorePluralizeWordStr;
					let param = {
						code : code,
						ignoreWords : ignoreWords
					}
					axios.post(`${baseUrl}/api/saveIgnoreWords`, param).then(response => {
						if (response.data.code == 200) {
							this.$message({type: 'success', message: '保存成功'});
							this.isShowSpellingDialog = false;
							this.isShowPluralizeDialog = false;
						} else {
							this.$message({type: 'error', message: response.msg});
						}
					})
					.catch(error => {
						console.log(error);
						this.$message({type: 'error', message: '请求失败'});
					})
				},
				// 处理代码逆向生成弹窗里面的向下填充的事件
				fillGeneratorFormData() {
					this.$confirm(`是否将此包名覆盖填充到下面的包名?`, '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						this.ruleGeneratorForm.packageMapperName = this.ruleGeneratorForm.packageEntityName;
						this.ruleGeneratorForm.packageMapperXmlName = this.ruleGeneratorForm.packageEntityName;
						this.ruleGeneratorForm.packageServiceName = this.ruleGeneratorForm.packageEntityName;
						this.ruleGeneratorForm.packageServiceImplName = this.ruleGeneratorForm.packageEntityName;
						this.ruleGeneratorForm.packageControllerName = this.ruleGeneratorForm.packageEntityName;
					}).catch(() => {
						        
					});
				},
            },
            mounted() {
				let that = this;
                this.list();
				this.listRegulationCheckType();
				this.getIgnoreWords(this.checkSpellingTypeCode);
				this.getIgnoreWords(this.checkPluralizeTypeCode);
				this.$nextTick(() => {
					let ruleGeneratorFormStr = localStorage.getItem("ruleGeneratorForm");
					if (ruleGeneratorFormStr != undefined && ruleGeneratorFormStr != null && ruleGeneratorFormStr.length > 0) {
						that.ruleGeneratorForm = JSON.parse(ruleGeneratorFormStr);
					}
				})
            }
        })
    </script>
</body>
</html>